package com.ipzoe.app.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ipzoe.cms.domain.StartPage;
import com.ipzoe.cms.enums.StartPageAppEnum;
import com.ipzoe.cms.enums.StartPageStatusEnum;
import com.ipzoe.cms.service.IStartPageService;
import com.ipzoe.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Validated
@Api(tags = "startPage相关")
@Slf4j
public class StartPageController {

    @Autowired
    private IStartPageService startPageService;

    /**
     * 查询前置页
     */
    @GetMapping("/api/v1/startPage")
    @ApiOperation("查询前置页")
    public AjaxResult get()
    {
        LambdaQueryWrapper<StartPage> lqw = new LambdaQueryWrapper<>();
        lqw.eq(StartPage::getApp, StartPageAppEnum.MICRO_APP.getCode())
                .eq(StartPage::getStatus, StartPageStatusEnum.ENABLE.getCode())
                .last("limit 1");
        StartPage startPage = startPageService.getOne(lqw);
        return AjaxResult.success(startPage);
    }
}